# app.py
from flask import Flask
from flask_cors import CORS
from config import Config
from models import db
from routes import main


def create_app(config_class=Config):
    app = Flask(__name__, static_folder='assets')
    app.config.from_object(config_class)

    # 初始化 CORS
    CORS(app)

    # 初始化数据库
    db.init_app(app)

    # 注册蓝图
    app.register_blueprint(main)

    return app

if __name__ == '__main__':
    app = create_app()
    with app.app_context():
        db.create_all()
    app.run(debug=True)
